package dailyquest

import (
	"encoding/json"
	"errors"
	"fmt"
	"kop/modules/configuration/client"
	"kop/modules/quest/configuration/dailyquest/type"
	"kop/util/log"
)

func init() {

	var err error
	if err = json.Unmarshal(client.Load("QuestDaily"), &Configs); err != nil {
		panic(err)
	}

	log.Info("Load QuestDaily.json success.")

}

// 主线任务配置
type Conf struct {
	ID              int32
	Type            _type.Type `json:"CheckType"`
	NeedValue       int64      `json:"Value1"` // 参数1 需要的数量
	AwardID         int32      // 奖励ID
	DailyQuestValue int32      `json:"Activation"` // 奖励的活跃度
}

var (
	Configs = map[int32]Conf{}
)

func GetByDailyQuestID(ID int32) (Conf, error) {

	var conf, ok = Configs[ID]
	if ok {
		return conf, nil
	}

	return Conf{}, errors.New(fmt.Sprintf("DailyQuestID not found [%d]", ID))
}
